export default defineNuxtPlugin(() => {
    ;(window as any)._hmt = (window as any)._hmt || []
    const hm = document.createElement('script')
    hm.src = 'https://hm.baidu.com/hm.js?3a39bc79413df8c0344910d9a941b1cc'
    const s = document.getElementsByTagName('script')[0] as any
    s.parentNode.insertBefore(hm, s)
    // 在这里添加你的插件代码
    // 例如，如果你想要添加一个全局方法或属性
    // nuxtApp.config.globalProperties.$myMethod = () => {
    //     // 你的代码
    // }
    const router = useRouter()
    router.afterEach(() => {
        // 页面路由切换后执行的代码
        // 例如，你想在每次路由切换后发送一个页面访问事件给百度统计
        if (process.client) {
            ;(window as any)._hmt = (window as any)._hmt || []
            ;(window as any)._hmt.push(['_trackPageview', location.pathname + location.search])
        }
    })
})
